<template>
	<view>
		<uni-datetime-picker :disabled="!isEdit" :type="field.type" v-model="value" @change="onChange" />
	</view>
</template>

<script>
	export default {
		props: {
			value: '',
			field: Object,
			isEdit: Boolean,
		},
		methods: {
			onChange(e) {
				this.$emit("update-value", new Date(e));
			},
		},

		data() {
			return {
				newData: ''
			};
		},


		mounted() {
			this.newData = this.value;
			setTimeout(() => {
				if (!this.newData) {
					this.newData = Date.now();
					this.$emit("update-value", this.newData);
				}
			}, 1000)
		},
	};
</script>

<style scoped>
	/* .picker {
		flex: 2;
		height: 40px;
		line-height: 40px;
		padding: 0 10px;
		border: 1px solid #ccc;
		border-radius: 4px;
		font-size: 14px;
		color: #333;
	}

	.value {
		flex: 2;
		font-size: 14px;
		color: #333;
	} */


	.uni-date-editor--x__disabled {
		opacity: 1;
	}
</style>
<style>
	.uni-date-editor--x__disabled {
		opacity: 1;
		cursor: default;
	}
</style>